<div class="toc">
  <h2>Table of Contents</h2>

  <ul>
  <% filter_results[:tocfilter].each do |hash| %>

    <li><a href="#<%= hash[:el].attributes["id"] %>"><%= hash[:el].content %></a></li>
    <% unless hash[:children].empty? %>
      <ul>
      <% hash[:children].each do |child| %>
        <li><a href="#<%= child[:el].attributes["id"] %>"><%= child[:el].content %></a></li>
      <% end %>
      </ul>
    <% end %>

  <% end %>
  </ul>
</div>